Persist changed-files expansion state per thread#1858
Persist changed-files expansion state per thread#1858juliusmarminge merged 6 commits intopingdotgg:mainfrom
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
apps/web/src/components/chat/MessagesTimeline.virtualization.browser.tsx
Show resolved
Hide resolved
The `?? {}` fallback treated a missing key in `right` as an empty
object, so two records with different outer keys but empty inner
values were incorrectly considered equal. Check `key in right`
before comparing inner records.
ApprovabilityVerdict: Approved Straightforward UI state persistence feature that remembers whether file change sections are expanded/collapsed per chat thread. The changes follow existing patterns in the codebase, are well-tested, and have no runtime behavior impact beyond local UI preferences stored in localStorage. You can customize Macroscope's approvability policy. Learn more. |
The branded schema API exposes `make`, not `makeUnsafe`.
Dismissing prior approval to re-evaluate b3979fc
What changed
MessagesTimelinecomponent state.uiStateStore, keyed by scoped thread id and turn id.Why
The changed-files tree reset to expanded whenever the thread view unmounted and mounted again. That happened because the expansion map lived inside
MessagesTimelineas local React state.Notes
MessagesTimeline.tsx, but for unrelated work.Validation
bun fmtbun lintbun typecheckbun run --cwd apps/web test --run src/uiStateStore.test.ts src/components/chat/MessagesTimeline.test.tsxNote
Persist changed-files expansion state per thread turn in UI store
threadChangedFilesExpandedByIdto uiStateStore.ts, tracking per-thread per-turn collapse state in localStorage. Only collapsed (false) states are stored to minimize persisted footprint.MessagesTimelinecomponent state into the parentChatView, passing it down via newchangedFilesExpandedByTurnIdandonSetChangedFilesExpandedprops.syncThreads) or their UI state is cleared (clearThreadUi).Macroscope summarized b3979fc.
Note
Low Risk
Low risk UI-state change: moves changed-files expand/collapse state from component-local state into the persisted
uiStateStore, with pruning/sanitization to avoid unbounded localStorage growth.Overview
Persists “Changed files” expand/collapse per thread/turn so the tree no longer resets when
MessagesTimelineunmounts/remounts.Adds
threadChangedFilesExpandedByIdtouiStateStore(including localStorage hydrate/sanitize, persist, and pruning viasyncThreads/clearThreadUi) and wiresChatViewto read/write this state and pass it intoMessagesTimeline, which is now controlled via newchangedFilesExpandedByTurnId/onSetChangedFilesExpandedprops. Tests were updated to cover the new store behavior and required props.Reviewed by Cursor Bugbot for commit b3979fc. Bugbot is set up for automated code reviews on this repo. Configure here.